package com.thesis.client;

import java.io.File;

import com.thesis.utils.Defines;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Environment;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

public class TableDetailActivity extends Activity {
	String[] receive;
	TextView tv_number;
	TextView tv_desc;
	ImageView iv_table;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_table_detail);
		Intent intent = getIntent();
		receive = intent.getStringArrayExtra(Defines.TABLE_DETAIL);
		ActionBar ab = getActionBar();
		ab.setTitle(getResources().getString(R.string.title_activity_table_detail)+" "+receive[0]);
		ab.setDisplayHomeAsUpEnabled(true);
		
		tv_number = (TextView) findViewById(R.id.td_tv_number);
		tv_desc = (TextView) findViewById(R.id.td_tv_desc);
		iv_table =(ImageView) findViewById(R.id.td_iv_table);
		
		tv_number.setText(receive[1]);
		tv_desc.setText(receive[2]);
		
		String	imagePath = Environment.getExternalStorageDirectory().toString() 
					+ "/restautant/table/" +receive[0]+".jpg";
		File file = new File(imagePath);
		if (file.exists())
			iv_table.setImageDrawable(Drawable.createFromPath(imagePath));	
		else iv_table.setImageResource(R.drawable.no_image);
		
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			finish();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}
//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		// Inflate the menu; this adds items to the action bar if it is present.
//		getMenuInflater().inflate(R.menu.table_detail, menu);
//		return true;
//	}

}
